package com.gaea.auth.vo;

import com.gaea.base.constants.CommonConstants;
import com.gaea.base.vo.UserVo;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @author bjsonghongxu
 * @create 2018-03-29 16:43
 **/
public class GaeaUserDetails implements UserDetails {

    private Long id; // 用户id
    private String  name; //用户名
    private String nickName;//昵称
    private String password; //密码
    private String mobile;
    private Integer dataStatus;



    public  GaeaUserDetails(UserVo userVo){
        this.id = userVo.getId();
        this.name = userVo.getName();
        this.nickName = userVo.getNickName();
        this.password = userVo.getPassword();
        this.mobile = userVo.getMobile();
        this.dataStatus = userVo.getDataStatus();
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.nickName;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return !(this.dataStatus != null && CommonConstants.LOCK_STATUS == this.dataStatus.intValue()) ;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return !(this.dataStatus != null && CommonConstants.USEALE_STATUS == this.dataStatus.intValue()) ;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Integer getDataStatus() {
        return dataStatus;
    }

    public void setDataStatus(Integer dataStatus) {
        this.dataStatus = dataStatus;
    }
}
